//
//  GetSiscountCouponCell.m
//  phmall
//
//  Created by admin on 2017/10/13.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "GetDiscountCouponCell.h"

@implementation GetDiscountCouponCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)theShareCellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"SetCell";
    GetDiscountCouponCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[GetDiscountCouponCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.contentView.backgroundColor=[UIColor groupTableViewBackgroundColor];
        self.back=[[UIView alloc]init];
        self.back.backgroundColor=[UIColor whiteColor];
        [self.contentView addSubview:self.back];
        
        self.colour=[[UIImageView alloc]init];
        self.colour.image=[UIImage imageNamed:@"一号店券"];
        [self.contentView addSubview:self.colour];
        
        self.logo=[[UIImageView alloc]init];
        self.logo.image=[UIImage imageNamed:@"一号店头像"];
        [self.contentView addSubview:self.logo];
        
        self.name=[[UILabel alloc]init];
        self.name.text=@"菲淘网1号店";
        self.name.textColor=[UIColor whiteColor];
        self.name.font=[UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.name];
        
        self.number=[[UILabel alloc]init];
        self.number.text=@"剩余1600张";
        self.number.textColor=[UIColor whiteColor];
        self.number.font=[UIFont systemFontOfSize:13];
        [self.contentView addSubview:self.number];
        
        self.title=[[UILabel alloc]init];
        self.title.text=@"· 进店购买立减";
        self.title.textColor=[UIColor blackColor];
        self.title.font=[UIFont systemFontOfSize:13];
        [self.contentView addSubview:self.title];
        
        self.subhead=[[UILabel alloc]init];
        self.subhead.text=@"· 不与本店其他活动函叠加使用";
        self.subhead.textColor=[UIColor blackColor];
        self.subhead.font=[UIFont systemFontOfSize:13];
        [self.contentView addSubview:self.subhead];
      
        self.price=[[UILabel alloc]init];
        self.price.text=@"P 334.58";
        self.price.textColor=[UIColor redColor];
        self.price.font=[UIFont systemFontOfSize:24];
        [self.contentView addSubview:self.price];
        
        self.purchase=[UIButton buttonWithType:UIButtonTypeCustom];
        [self.purchase setTitle:@"立即抢" forState:UIControlStateNormal];
        self.purchase.backgroundColor=[UIColor colorWithHexString:@"#FFCE49"];
        ViewBorderRadius(self.purchase, 5, 0, [UIColor clearColor]);
        [self.contentView addSubview:self.purchase];
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.contentView.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    [self.back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10).priorityHigh();
        make.right.equalTo(self.contentView).offset(-10).priorityHigh();
        make.top.equalTo(self.contentView).offset(5).priorityHigh();
        make.bottom.equalTo(self.contentView).offset(-5).priorityHigh();
    }];
    ViewBorderRadius(self.back, 5, 0, [UIColor clearColor]);
    
    [self.colour mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.back);
        make.height.offset(100);
    }];

    [self.logo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self.colour).offset(20);
        make.bottom.equalTo(self.colour).offset(-20);
        make.width.equalTo(self.logo.mas_height);
    }];

    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.back).offset(30);
        make.left.equalTo(self.logo.mas_right).offset(20);
    }];

    [self.number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.name.mas_bottom).offset(10);
        make.left.equalTo(self.name);
    }];

    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.back).offset(10);
        make.top.equalTo(self.colour.mas_bottom).offset(10);
    }];

    [self.subhead mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.back).offset(10);
        make.top.equalTo(self.title.mas_bottom).offset(15);
    }];

    [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.back).offset(-10);
        make.bottom.equalTo(self.subhead);
    }];
    
    [self.purchase mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.back).offset(-10);
        make.centerY.equalTo(self.logo);
        make.width.offset(80);
        make.height.offset(30);
    }];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
